for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
// eslint-disable-next-line no-unused-vars
class Background {
constructor(options) {
if (options) {
this.elm = Background.formatElm(options.elm);
this.class = Background.formatClass(options.class);
}
static formatElm(elm) {
if (typeof elm === 'object') return elm;
return document.querySelector(`${elm}`);
static formatClass(_class) {
if (_class.indexOf('.') === 0) {
return _class.substr(1);
return _class;
addAfter(wait = 0) {
if (wait) {
setTimeout(() => {
this.elm.classList.add(this.class);
}, wait);
} else {
return this;
removeAfter(wait = 0) {
this.elm.classList.remove(this.class);
removeAllAfter(wait = 0) {
const elms = document.querySelectorAll(`.${this.class}`);
if (!elms) return;
elms.forEach(elm => elm.classList.remove(this.class));